package com.example.a10928.weifriend.data.pref;

import android.content.Context;


import com.example.a10928.weifriend.AppScope;

import javax.inject.Inject;

import static com.example.a10928.weifriend.App.app;


/**
 * Created by Chuang on 2018/3/2.
 * 此处放应用级的配置
 * 用户级的放在{@link UserPerfManager}
 * <p>
 */

@AppScope
public class DefaultPrefManager extends BasePrefManager {
    private static final String KEY_USER_JSON = "user_json";


    private static final String KEY_COUNTRY_ID = "country_id";

    @Inject
    DefaultPrefManager(Context context) {
        super(context, android.preference.PreferenceManager.getDefaultSharedPreferences(context), app().getGson());
    }


    public String getUserJson() {
        return mPref.getString(KEY_USER_JSON, "");
    }

    public void setUserJson(String json) {
        mPref.edit().putString(KEY_USER_JSON, json).apply();
    }

    public String getKeyString(String key) {
        return mPref.getString(key, "");
    }

    public void setKeyString(String key, String url) {
        mPref.edit().putString(key, url).apply();
    }

    public void setKeyCountryId(int id) {
        mPref.edit().putInt(KEY_COUNTRY_ID, id).apply();
    }

    public int getKeyCountryId() {
        return mPref.getInt(KEY_COUNTRY_ID, 43);
    }

}
